Ext.extend(app.module,{
    currentFormValues: {},
    init: function(){
        mainPanel = this;
        //用于列表
        this.userds = new Ext.data.Store({
            proxy: new Ext.data.HttpProxy({url:'user/list.do'}),
            reader: new Ext.data.JsonReader({
                totalProperty: 'total',
                root: 'rows',
                idProperty: 'id'
            },[
                {name:'id'},
                {name:'name'},
                {name:'username'},
                {name:'deptid'},
                {name:'deptname'},
                {name:'job'},
                {name:'telephone'},
                {name:'titleid'},
                {name:'titlename'},
                {name:'roleIds'},
                {name:'roleNames'},
                {name:'subjectid'},
                {name:'subjectname'}
            ])
        });
        // 翻页排序时带上查询条件
        this.userds.on('beforeload', function() {
            this.baseParams = {
                name : Ext.getCmp('userQueryName').getValue(),
                username : Ext.getCmp('userQueryUserName').getValue(),
                deptids : Ext.getCmp('userQueryDept').getValue()
            };
        });
        //选择职称的下拉菜单所需数据
        this.titleStore = new Ext.data.Store({
            proxy: new Ext.data.HttpProxy({url:'title/list.do'}),
            reader: new Ext.data.JsonReader({
                root: 'rows',
                idProperty: 'id'
            },[
                {name:'id'},
                {name:'name'}
            ])
        });
        //选择学科组的下拉菜单所需数据
        this.subjectStore = new Ext.data.Store({
            proxy: new Ext.data.HttpProxy({url:'subject/list.do'}),
            reader: new Ext.data.JsonReader({
                root: 'rows',
                idProperty: 'id'
            },[
                {name:'id'},
                {name:'name'}
            ])
        });
        this.loader = new Ext.tree.JsonPluginTreeLoader({dataUrl:'dept/getDeptTree.do'});
        deptTree = new Ext.tree.TreePanel( {
            loader: mainPanel.loader,
            root : {
                id: 0,
                text: '根节点',
                expanded: true
            },
            autoScroll : false,
            rootVisible : false,// 根节点是否可见
            animate : false,    // 展开,收缩动画
            useArrows : false,  // 是否使用箭头样式
            lines:false,        // 去掉树的线
            border : false
        });
        // 监听下拉树的节点单击事件
        deptTree.on('click', function(node) {
            //递归获取所有子节点
            var getChild = function(n){
                if(!n.leaf){
                    var nodes = n.childNodes;
                    for(var i=0;i<nodes.length;i++){
                        deptids.push(nodes[i].id);
                        getChild(nodes[i]);
                    }
                }
            }
            var deptids = [];
            deptids.push(node.id);
            getChild(node);
            mainPanel.comboxWithTree.setValue(node.text);
            Ext.getCmp('userQueryDept').setValue(deptids);
            mainPanel.comboxWithTree.collapse();
        });
        if(!this.comboxWithTree){
            this.comboxWithTree = new Ext.form.ComboBox({
                store : new Ext.data.SimpleStore( {
                    fields : [],
                    data : [[]]
                }),
                autoScroll : true,
                value : ' ',
                emptyText : '请选择部门...',
                mode : 'local',
                triggerAction : 'all',
                maxHeight : 390,
                // 下拉框的显示模板,deptTreeDiv作为显示下拉树的容器
                tpl : "<tpl for='.'><div style='height:390px'><div id='deptTreeDiv'></div></div></tpl>",
                onSelect : Ext.emptyFn,
                onViewClick : Ext.emptyFn,
                assertValue : Ext.emptyFn
            });
        }
        // 监听下拉框的下拉展开事件
        this.comboxWithTree.on('expand', function() {
            // 将树挂到treeDiv容器
            deptTree.render('deptTreeDiv');
        });

        var user_pagesize_combo = new Ext.form.ComboBox( {       //设置分页栏的每页记录数选择
            name : 'pagesize',
            hiddenName : 'pagesize',
            typeAhead : true,
            triggerAction : 'all',
            lazyRender : true,
            mode : 'local',
            store : new Ext.data.ArrayStore(
                {
                    fields : [ 'value', 'text' ],
                    data : [ [ 10, '10条/页' ], [ 20, '20条/页' ],
                        [ 50, '50条/页' ], [ 100, '100条/页' ],
                        [ 250, '250条/页' ], [ 500, '500条/页' ] ]
                }),
            valueField : 'value',
            displayField : 'text',
            value : '20',
            editable : false,
            width : 85
        });
        var number = parseInt(user_pagesize_combo.getValue());

        user_pagesize_combo.on("select", function(comboBox) {
            var bbar = Ext.getCmp('userbbar');
            bbar.pageSize = parseInt(comboBox.getValue());
            number = parseInt(comboBox.getValue());
            mainPanel.userds.reload( {
                params : {
                    start : 0,
                    limit : bbar.pageSize
                }
            });
        });

        this.sm = new Ext.grid.CheckboxSelectionModel();
        this.body = new Ext.grid.GridPanel({
            store: this.userds,
            region: 'center',
            loadMask: true,
            viewConfig:{
                forceFit:true
            },
            sm: this.sm,
            columns: [
                new Ext.grid.RowNumberer(),
                this.sm,
                {
                    xtype: 'gridcolumn',
                    dataIndex: 'id',
                    header: 'id',
                    hidden: true
                },
                {
                    xtype: 'gridcolumn',
                    align: 'center',
                    dataIndex: 'name',
                    header: '登录名'
                },
                {
                    xtype: 'gridcolumn',
                    align: 'center',
                    dataIndex: 'username',
                    header: '用户名'
                },
                {
                    xtype: 'gridcolumn',
                    align: 'center',
                    dataIndex: 'titleid',
                    hidden: true
                },
                {
                    xtype: 'gridcolumn',
                    align: 'center',
                    dataIndex: 'titlename',
                    header: '职称'
                },
                {
                    xtype: 'gridcolumn',
                    align: 'center',
                    dataIndex: 'job',
                    header: '职务'
                },
                {
                    xtype: 'gridcolumn',
                    align: 'center',
                    dataIndex: 'deptname',
                    header: '部门名称'
                },
                {
                    xtype: 'gridcolumn',
                    align: 'center',
                    dataIndex: 'telephone',
                    header: '联系电话'
                },
                {
                    xtype: 'gridcolumn',
                    align: 'center',
                    dataIndex: 'subjectname',
                    header: '学科组'
                },
                {
                    xtype: 'gridcolumn',
                    align: 'center',
                    dataIndex: 'roleNames',
                    header: '角色'
                }
            ],
            tbar: {
                xtype: 'toolbar',
                items: [
                    {
                        text: '新增',
                        iconCls : 'user_add',
                        scope: this,
                        handler: this.add
                    },
                    '-',
                    {
                        text: '修改',
                        iconCls : 'user_edit',
                        scope: this,
                        handler: this.edit
                    },
                    '-',
                    {
                        text: '删除',
                        iconCls : 'user_delete',
                        scope: this,
                        handler: this.del
                    },
                    '-',
                    {
                        text: '重置密码',
                        iconCls : 'btn-undo',
                        scope: this,
                        handler: this.resetPass
                    },
                    '-',
                    {
                        text: '关联角色',
                        iconCls : 'btn-save',
                        scope: this,
                        handler: this.glRole
                    },
                    {
                        text: '导入',
                        iconCls : 'user_add',
                        scope: this,
                        handler: this.importFromExcel
                    },
                    '->',
                    {
                        xtype: 'displayfield',
                        value: '查询条件：'
                    },
                    this.comboxWithTree,
                    {
                        xtype: 'textfield',
                        id : 'userQueryDept',
                        hidden: true
                    },
                    ' ',
                    {
                        xtype: 'textfield',
                        id : 'userQueryName',
                        name : 'userQueryName',
                        emptyText : '请输入登录名',
                        enableKeyEvents : true,
                        listeners : {
                            specialkey : function(field, e) {
                                if (e.getKey() == Ext.EventObject.ENTER) {
                                    mainPanel.query();
                                }
                            }
                        },
                        width : 100
                    },
                    ' ',
                    {
                        xtype: 'textfield',
                        id : 'userQueryUserName',
                        name : 'userQueryUserName',
                        emptyText : '请输入用户名',
                        enableKeyEvents : true,
                        listeners : {
                            specialkey : function(field, e) {
                                if (e.getKey() == Ext.EventObject.ENTER) {
                                    mainPanel.query();
                                }
                            }
                        },
                        width : 100
                    },
                    {
                        text : '查询',
                        iconCls : 'btn-search',
                        handler : function() {
                            mainPanel.query();
                        }
                    }

                ]
            },
            bbar: {
                id: 'userbbar',
                xtype: 'paging',
                pageSize : number,
                store : this.userds,
                displayInfo : true,
                displayMsg : '显示{0}条到{1}条,共{2}条',
                emptyMsg : "没有符合条件的记录",
                items : [ '-', '&nbsp;&nbsp;', user_pagesize_combo ]
            }
        });
        this.main.add(this.body);
        this.main.doLayout();
        this.userds.load({
            params: {
                start:0,
                limit:20
            }
        });
    },
    getUserDialog: function(){
        this.form = this.getForm();
        var dlg = new Ext.Window({
            height: 280,
            width: 400,
            layout: 'fit',
            border: false,
            frame: true,
            title: '',
            modal: true,
            plain: true,
            resizable: false,
            items: [this.form],
            listeners: {
                scope: this,
                render: function(fp){
                    this.form.getForm().waitMsgTarget = fp.getEl();
                },
                show: function(){
                    var f = this.form.getForm();
                    f.setValues(this.currentFormValues);
                    f.clearInvalid();
                }
            }
        });
        return dlg;
    },
    getForm: function() {
        mainPanel = this;
        this.comboTitle = new Ext.form.ComboBox({
            store: this.titleStore,
            editable: false,
            emptyText: '请选择职称...',
            mode: 'local',
            hiddenName : 'titleid',
            typeAhead : true,
            triggerAction : 'all',
            displayField: 'name',
            valueField: 'id',
            fieldLabel: '职称'
        });
        this.comboSubject = new Ext.form.ComboBox({
            store: this.subjectStore,
            editable: false,
            emptyText: '请选择学科组...',
            mode: 'local',
            hiddenName : 'subjectid',
            typeAhead : true,
            triggerAction : 'all',
            displayField: 'name',
            valueField: 'id',
            fieldLabel: '学科组'
        });
        selectDeptTree = new Ext.tree.TreePanel( {
            loader: this.loader,
            root : {
                id: 0,
                text: '根节点',
                expanded: true
            },
            autoScroll : false,
            rootVisible : false,// 根节点是否可见
            animate : false,    // 展开,收缩动画
            useArrows : false,  // 是否使用箭头样式
            lines:false,        // 去掉树的线
            border : false
        });
        // 监听下拉树的节点单击事件
        selectDeptTree.on('click', function(node) {
            if(node.leaf){
                mainPanel.comboxWithDeptTree.setValue(node.text);
                Ext.getCmp('userDept').setValue(node.id);
                mainPanel.comboxWithDeptTree.collapse();
            } else {
                Ext.Msg.alert("提示","不能选择有下级部门的节点！");
            }
        });
        this.comboxWithDeptTree = new Ext.form.ComboBox({
            fieldLabel: '所属部门',
            store : new Ext.data.SimpleStore( {
                fields : [],
                data : [[]]
            }),
            autoScroll : true,
            value : '',
            emptyText : '请选择部门...',
            mode : 'local',
            editable: false,
            triggerAction : 'all',
            maxHeight : 390,
            // 下拉框的显示模板,deptTreeDiv作为显示下拉树的容器
            tpl : "<tpl for='.'><div style='height:390px'><div id='userSelectDeptTreeDiv'></div></div></tpl>",
            allowBlank : false,
            onSelect : Ext.emptyFn,
            onViewClick : Ext.emptyFn,
            assertValue : Ext.emptyFn
        });
        // 监听下拉框的下拉展开事件
        this.comboxWithDeptTree.on('expand', function() {
            // 将树挂到treeDiv容器
            selectDeptTree.render('userSelectDeptTreeDiv');
        });

        var form = new Ext.form.FormPanel({
            defaultType: 'textfield',
            bodyStyle: 'padding:5px',
            buttonAlign: 'center',
            url:'user/save.do',
            labelWidth: 80,
            defaults: {
                anchor: '90%'
            },
            items: [
                {
                    xtype: 'hidden',
                    name: 'id'
                },
                {
                    xtype: 'textfield',
                    name: 'name',
                    allowBlank: false,
                    emptyText: '登录名不能为空',
                    fieldLabel: '登录名'
                },
                {
                    xtype: 'textfield',
                    name: 'username',
                    allowBlank: false,
                    emptyText: '用户名不能为空',
                    fieldLabel: '用户名'
                },
                this.comboTitle,
                {
                    xtype: 'textfield',
                    name: 'job',
                    emptyText: '若无职务留空',
                    fieldLabel: '职务'
                },
                {
                    xtype: 'textfield',
                    name: 'telephone',
                    fieldLabel: '联系电话'
                },
                {
                    xtype: 'textfield',
                    name: 'deptid',
                    id: 'userDept',
                    hidden: true
                },
                this.comboxWithDeptTree,
                this.comboSubject
            ],
            buttons: [{
                text: '确定',
                scope: this,
                handler: function() {
                    this.submit();
                }
            },
                {
                    text: '重置',
                    scope: this,
                    handler: function() {
                        var f = this.form.getForm();
                        f.reset();
                        f.setValues(this.currentFormValues);
                        f.clearInvalid();
                    }
                }]
        });
        return form;
    },
    submit: function(){
        if (this.form.getForm().isValid()) {
            var id = this.form.getForm().findField("id").getValue();
            this.form.getForm().submit({
                waitTitle: '保存数据',
                waitMsg: '正在保存……',
                scope: this,
                method: 'post',
                params: '',
                submitEmptyText: false,     //禁止提交emptyText
                success: function(form, action) {
                    var info = action.result.info;
                    if (action.result.success) {
                        this.userds.reload();
                        if (action.result.method == "Create") {
                            this.form.getForm().reset();
                        } else {
                            this.dlg.close();
                        }
                    }
                    Ext.Msg.alert('信息', info);
                },
                failure: function(form, action) {
                    var info = action.result.info;
                    Ext.Msg.alert('提示', info);
                }
            });
        }
    },
    add: function() {
        this.titleStore.load({
            add: false
        });
        this.subjectStore.load({
            add: false
        });
        this.dlg = this.getUserDialog();
        Ext.apply(this.currentFormValues, {
            id: '',
            name: "",
            username: "",
            deptid: ""

        });
        this.comboTitle.setValue('');
        this.comboSubject.setValue('');
        this.comboxWithDeptTree.setValue('');
        this.dlg.setTitle("增加用户");
        this.dlg.show();
    },

    edit: function() {
        mainPanel = this;
        this.dlg = this.getUserDialog();
        var recs = this.body.getSelectionModel().getSelections();
        if (recs.length==0) {
            Ext.Msg.alert('信息', '请选择要编辑的用户。');
        } else if(recs.length>1) {
            Ext.Msg.alert('信息', '只能选择一个用户进行编辑。');
        } else {
            this.dlg.setTitle("编辑用户");
            Ext.apply(this.currentFormValues, {
                id: recs[0].data.id,
                name: recs[0].data.name,
                username: recs[0].data.username,
                deptid: recs[0].data.deptid
            });
            this.titleStore.load({
                add: false, //表示到底是追加数据，还是替换数据，false为替换,如果不设置为替换，表单会被搞乱
                callback: function () {
                    //等待数据加载完成才进行赋值，不然由于异步会出现先赋值后加载完成。
                    mainPanel.comboTitle.setValue(recs[0].data.titleid);
                }
            });
            this.subjectStore.load({
                add: false, //表示到底是追加数据，还是替换数据，false为替换,如果不设置为替换，表单会被搞乱
                callback: function () {
                    //等待数据加载完成才进行赋值，不然由于异步会出现先赋值后加载完成。
                    mainPanel.comboSubject.setValue(recs[0].data.subjectid);
                }
            });
            this.comboxWithDeptTree.setValue(recs[0].data.deptname);
            this.dlg.show();
        }
    },

    del: function() {
        mainPanel = this;
        if (this.body.getSelectionModel().hasSelection()) {
            var recs = this.body.getSelectionModel().getSelections();
            var ids = [];
            var titles = [];
            for (var i = 0; i < recs.length; i++) {
                var data = recs[i].data;
                ids.push(data.id);
                titles.push(data.name);
            }
            Ext.Msg.confirm('删除用户', '确定删除以下用户？<br><font color="red">' + titles.toString() + '</font>',
                function(btn) {
                    if (btn == 'yes') {
                        Ext.Ajax.request({
                            method:'post',
                            url:'user/remove.do',
                            params:{
                                ids:ids.toString()
                            },
                            scope: mainPanel,
                            success: function(resp, opts) {
                                var result = Ext.util.JSON.decode(resp.responseText);
                                var info = result.info;
                                if(result.success=='true') {
                                    this.userds.reload();
                                    Ext.Msg.alert('信息', info);
                                }else {
                                    Ext.Msg.alert('信息', info);
                                }
                            },
                            failure: function(resp,opts) {
                                var result = Ext.util.JSON.decode(resp.responseText);
                                var info = result.info;
                                Ext.Msg.alert('提示', info);
                            }
                        });
                    }
                });
        } else {
            Ext.Msg.alert('信息', '请选择要删除的用户！');
        }
    },
    query: function(){
        this.userds.load( {
            params : {
                start : 0,
                limit : Ext.getCmp('userbbar').pageSize,
                name : Ext.getCmp('userQueryName').getValue(),
                username : Ext.getCmp('userQueryUserName').getValue(),
                deptids : Ext.getCmp('userQueryDept').getValue()
            }
        });
    },
    resetPass: function(){
        mainPanel = this;
        if (this.body.getSelectionModel().hasSelection()) {
            var recs = this.body.getSelectionModel().getSelections();
            var ids = [];
            var titles = [];
            for (var i = 0; i < recs.length; i++) {
                var data = recs[i].data;
                ids.push(data.id);
                titles.push(data.name);
            }
            Ext.Msg.confirm('重置密码', '确定将以下用户密码重置？<br><font color="red">' + titles.toString() + '</font>',
                function(btn) {
                    if (btn == 'yes') {
                        Ext.Ajax.request({
                            method:'post',
                            url:'user/resetPass.do',
                            params:{
                                ids:ids.toString()
                            },
                            scope: mainPanel,
                            success: function(resp, opts) {
                                var result = Ext.util.JSON.decode(resp.responseText);
                                var info = result.info;
                                if(result.success=='true') {
                                    this.userds.reload();
                                    Ext.Msg.alert('信息', info);
                                }else {
                                    Ext.Msg.alert('信息', info);
                                }
                            },
                            failure: function(resp,opts) {
                                var result = Ext.util.JSON.decode(resp.responseText);
                                var info = result.info;
                                Ext.Msg.alert('提示', info);
                            }
                        });
                    }
                });
        } else {
            Ext.Msg.alert('信息', '请选择密码重置的用户！');
        }
    },
    glRole: function(){
        mainPanel = this;
        var recs = this.body.getSelectionModel().getSelections();
        if (recs.length==0) {
            Ext.Msg.alert('信息', '请选择要编辑的用户。');
        } else {
            var roleStore = new Ext.data.Store({
                proxy: new Ext.data.HttpProxy({url:'role/list.do'}),
                reader: new Ext.data.JsonReader({
                    totalProperty: 'total',
                    root: 'rows',
                    idProperty: 'id'
                },[
                    {name:'id'},
                    {name:'name'},
                    {name:'description'}
                ])
            });
            roleStore.load({
                add: false, //表示到底是追加数据，还是替换数据，false为替换,如果不设置为替换，表单会被搞乱
                callback: function () {
                    //等待数据加载完成
                    var roleCheckboxItems = [];
                    for(var i=0;i<roleStore.getCount();i++){
                        var boxLabel = roleStore.getAt(i).get("name");
                        var name = roleStore.getAt(i).get("id");
                        var isChecked = false;
                        //如果只选了一个用户，那么显示出该用户已有角色
                        if(recs.length==1 && recs[0].data.roleIds!=null){
                            var userRoles = recs[0].data.roleIds.split(",");
                            Ext.each(userRoles, function(r){
                                if(r==name){
                                    isChecked = true;
                                }
                            },this);
                        }
                        roleCheckboxItems.push({
                            boxLabel : boxLabel,
                            value : name,
                            checked : isChecked
                        })
                    }
                    var columNum=3; //设置checkbox的列数,默认是3
                    //算出高度
                    var dlgHeight = 70+(parseInt((roleStore.getCount()-1)/3)+1)*30;
                    if(columNum<3)   //如果checkbox个数小于3时，列的长度设成checkbox个数
                        columNum=comData.length;
                    var myCheckboxGroup = new Ext.form.CheckboxGroup({
                        name:'operationShow',
                        xtype : 'checkboxgroup',
                        columns: columNum,
                        items : roleCheckboxItems
                    });

                    var glRoleForm=new Ext.form.FormPanel({
                        buttonAlign:'center',
                        labelAlign:'right',
                        labelWidth:5,
                        frame:true,
                        method:"post",
                        url:'user/glRole',
                        items:[myCheckboxGroup],
                        buttons: [
                            {
                                text: '保存',
                                scope: this,
                                handler: function() {
                                    var selectRoleIds = [];
                                    var selectUserids = [];
                                    //CheckboxGroup取值
                                    for (var i = 0; i < myCheckboxGroup.items.length; i++)
                                    {
                                        if (myCheckboxGroup.items.itemAt(i).checked)
                                        {
                                            selectRoleIds.push(myCheckboxGroup.items.itemAt(i).value);
                                        }
                                    }
                                    for (var i = 0; i < recs.length; i++)
                                    {
                                        selectUserids.push(recs[i].data.id);
                                    }
                                    Ext.Ajax.request({
                                        method:'post',
                                        url:'user/glRole.do',
                                        params:{
                                            roleids:selectRoleIds.join(','),
                                            userids:selectUserids.join(',')
                                        },
                                        scope: mainPanel,
                                        success: function(resp, opts) {
                                            var result = Ext.util.JSON.decode(resp.responseText);
                                            var info = result.info;
                                            if(result.success=='true') {
                                                Ext.Msg.alert('信息', info);
                                            }else {
                                                Ext.Msg.alert('信息', info);
                                            }
                                            this.userds.reload();
                                            glRoleDlg.close();
                                        },
                                        failure: function(resp,opts) {
                                            var result = Ext.util.JSON.decode(resp.responseText);
                                            var info = result.info;
                                            Ext.Msg.alert('提示', info);
                                        }
                                    });
                                }
                            },
                            {
                                text: '取消',
                                scope: this,
                                handler: function() {
                                    glRoleDlg.close();
                                }
                            }
                        ]
                    });

                    var glRoleDlg = new Ext.Window({
                        autoScroll: true,
                        height: dlgHeight,
                        width: 400,
                        layout: 'fit',
                        border: false,
                        frame: true,
                        title: '关联角色',
                        modal: true,
                        plain: true,
                        items: [glRoleForm],
                        listeners: {
                            scope: this,
                            render: function(fp){
                                glRoleForm.getForm().waitMsgTarget = fp.getEl();
                            }
                        }
                    });

                    glRoleDlg.show();

                }
            });
        }
    },
    importFromExcel: function(projectid,isagree){
        mainPanel = this;
        var form = new Ext.form.FormPanel({
            labelAlign: 'right',
            bodyStyle: 'padding:5px',
            buttonAlign: 'right',
            frame: true,
            fileUpload: true,
            url:'user/import.do',
            labelWidth: 80,
            allowBlank: false,
            msgTarget: 'side',
            defaults: {
                anchor: '90%'
            },
            items: [
                {
                    xtype: 'textfield',
                    name: 'file',
                    allowBlank: false,
                    fieldLabel: '选择文件',
                    inputType: 'file'
                }
            ],
            buttons: [{
                text: '提交',
                scope: this,
                handler: function() {
                    if (form.getForm().isValid()) {
                        form.getForm().submit({
                            waitTitle: '保存数据',
                            waitMsg: '正在保存……',
                            scope: this,
                            method: 'POST',
                            params: {projectid:projectid},
                            submitEmptyText: false,     //禁止提交emptyText
                            success: function(form, action) {
                                Ext.Msg.alert('信息', action.result.info);
                                dlg.close();
                                this.userds.reload();
                            },
                            failure: function(form, action) {
                                if(action.result.sessionstatus=='timeout'){
                                    alert("出于安全原因，请重新登录！");
                                    //发现请求超时，退出处理代码...
                                    var win = window;
                                    while (win != win.parent){
                                        win = win.parent;
                                    }
                                    win.location = "index.jsp";
                                } else {
                                    Ext.Msg.alert('提示', action.result.info);
                                    dlg.close();
                                    this.userds.reload();
                                }
                            }
                        });
                    }
                }
            }]
        });
        var dlg = new Ext.Window({
            height: 140,
            width: 500,
            layout: 'fit',
            border: false,
            frame: true,
            title: '只支持excel 2003格式的文件',
            modal: true,
            plain: true,
            resizable: false,
            items: [form],
            listeners: {
                scope: this,
                render: function(fp){
                    form.getForm().waitMsgTarget = fp.getEl();
                },
                show: function(){
                    var f = form.getForm();
                    f.clearInvalid();
                }
            }
        });
        dlg.show();
    }
});